const mongoose = require('mongoose')
const { DB_URL } = require('./index')
mongoose.set('useCreateIndex', true)
mongoose.connect(DB_URL, { useNewUrlParser: true, useUnifiedTopology: true })
mongoose.connection.on('connected', () => {
  console.log('mongoose connection open to ' + DB_URL)
})
mongoose.connection.on('error', err => {
  console.log('Mongoose connection error: ' + err)
})
mongoose.connection.on('disconnected', () => {
  console.log('Mongoose connection disconnected')
})
module.exports = mongoose
